package m202406.d25;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

/**
 * @@author: 爱做梦的锤子
 * @date: 2024/6/25 22:28
 */
public class LCR80 {
    public List<List<Integer>> combine(int n, int k) {
        List<List<Integer>> res = new ArrayList<>();
        select(n, 1, k, new LinkedList<>(), res);
        return res;
    }

    private void select(int n, int index, int k, LinkedList<Integer> list, List<List<Integer>> res) {
        if (list.size() == k) {
            res.add(new ArrayList<>(list));
            return;
        }
        for (int i = index; i <= n; i++) {
            list.addLast(i);
            select(n, i + 1, k, list, res);
            list.removeLast();
        }
    }
}
